package org.jflame.context.spring.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

public abstract class BaseMakableAspect {

    private final KeyExprParseContext keyContext = new KeyExprParseContext();

    public void addKeyParsers(KeyExprParser... _parsers) {
        keyContext.addParsers(_parsers);
    }

    public void setDefaultKeyParsers(KeyExprParser _parser) {
        keyContext.setDefaultParser(_parser);
    }

    public KeyExprParseContext getKeyExprParseContext() {
        return keyContext;
    }

    protected String parseInovkeKey(String keyExpr, JoinPoint joinPoint) {
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        return keyContext.parse(keyExpr, signature.getMethod(), joinPoint.getArgs());
    }
}
